<template>
  <div>
    <h1>注册</h1>
    <p>用户名：<input type="text" v-model="form.username" @blur="fs">{{ mes.username }}</p>
    <p>密码：<input type="text" v-model="form.password"></p>
    <p>手机号：<input type="text" v-model="form.phone"></p>
    <p>短信验证<input type="text" v-model="xinxi" @blur="xx">{{ mes.xin }}
      <button @click="fs" :disabled="flag">发送</button>
    </p>
    <p>
      <button>注册</button>
    </p>
  </div>
</template>

<script>
export default {
  name: "reg",
  data() {
    return {
      form: {},
      xinxi: '',
      flag: false,
      mes: {username: '', xin: ''}
    }
  },
  methods: {
    fs() {
      let username = this.form.username
      if (username == undefined || username == null || username == '') {
        this.mes.username = '不能为空'
        return false
      }
      this.$axios.post('users/DuserAPI/', this.form)
        .then(res => {
          if (res.data.code == 10010) {
            this.mes = '不能为空'
            return false
          }
          if (res.data.code == 200) {
            this.mes = ''
          }
        })
      },
    xx() {
      let xxs = this.xinxi
      if (xxs == '' || xxs == null || xxs == undefined){
        this.mes.xin = '不能为空'
        return false
      }
      this.$axios.post('usres/0/')
    }
  }
}
</script>

<style scoped>

</style>

